package cn.tradewin.pmp.components;

import org.apache.tapestry5.BindingConstants;
import org.apache.tapestry5.Block;
import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.annotations.Environmental;
import org.apache.tapestry5.annotations.Import;
import org.apache.tapestry5.annotations.Parameter;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.ioc.Messages;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.services.javascript.JavaScriptSupport;

@Import(stylesheet = { "css/font-awesome.css", "layoutmaster.css" })
public class layoutmaster {

	/**
     * The page title, for the <title> element and the <h1> element.
     */
    @Property
    @Parameter(required = true, defaultPrefix = BindingConstants.LITERAL)
    private String title;
    
//    @Property
//    @Parameter(defaultPrefix = BindingConstants.LITERAL)
//    private Block content;
//    
    @Property
    private String pageName;
	
	@Inject
	private ComponentResources resources;
	
	@Environmental
	private JavaScriptSupport js;
	
	void afterRender() {
		js.require("jquery");
		js.require("bootstrap");
	}
	
	@Inject
	Messages messages;
	
	public String[] getPageNames() {
		return new String[] {"master/CustomerManage", "master/DeptManage", "master/EmpManage", "master/PositionManage", "master/TaskBoard"};
	}
	
	public String getNaviCss() {
		 return resources.getPageName().equalsIgnoreCase(pageName) ? "active" : null;
	}
	
	public String getNaviLabel() {
		return messages.get(pageName);
	}	
}